<?php
function p($var)
{
    echo '<pre>';
    print_r($var);
    echo '</pre>';
}

function dd($var)
{
    echo '<pre>';
    print_r($var);
    echo '</pre>';
    die();
}

function formatJson($code, $msg = '', $data = '')
{
    $jsond['error_code'] = $code;
    $jsond['error_msg'] = empty($msg) ? app\lib\Code::getMsg($code) : $msg;
    $jsond['data'] = $data;
    ajaxReturn($jsond);
}

function ajaxReturn($data)
{
    // 返回JSON数据格式到客户端 包含状态信息
    header('Content-Type:application/json; charset=utf-8');
    echo json_encode($data);
    exit();
}

